﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace Happy.CodeRule.Generators
{
    /// <summary>
    /// 字面量编号生成器解释器。
    /// </summary>
    public sealed class LiteralCodeGeneratorInterceptor : ICodeRuleInterceptor
    {
        private static readonly Regex _Regex = new Regex(@"^[^<\(].*?[^>\)]?$");

        /// <inheritdoc />
        public bool IsMatch(string codeRule)
        {
            return _Regex.IsMatch(codeRule);
        }

        /// <inheritdoc />
        public ICodeGenerator Intercept(string codeRule)
        {
            return new LiteralCodeGenerator(codeRule);
        }
    }
}
